//
//  YYUtils.swift
//  STMusic
//
//  Created by stoneobs on 17/4/6.
//  Copyright © 2017年 stoneobs. All rights reserved.
//

import UIKit

class YYUtils: NSObject {

    //返回时长
    static func musicDuring(during:Int) -> String{
    
        let minite = during / 60;
        let secend = during % 60;
        let finsh = String(minite) + "'" + String(secend) + "'";
        return finsh;
        
    }
    //返回发布时间
    static func musicCreateTime(create:Int) -> String{
        
        var date:NSDate = NSDate.init(timeIntervalSince1970: TimeInterval(create));
        date = date.local() as NSDate;
        
        let nowDate = NSDate().local() as NSDate;
        let num = Int(nowDate.timeIntervalSince1970)  - 3600 * 8;//swift 转出来又是差8小时
        
        let chazhi = num - create;
        var finsh:String?;
        if  chazhi <= (24 * 60 * 60) {
        
            let hour  =  chazhi / (60 * 60 );
            let minite = (chazhi - hour*3600) / 60 ;
            if hour > 0 {
                finsh = String(hour) + "小时前";
            }else{
                finsh = String(minite) + "分钟前";
            }
            
            
        }else{
        
            return date.yyyyMMddByLineWithDate();
        }
     
        return finsh!;
        
    }
    
    static func bmobErrorDes(error:Error) -> String {
        
        let myerror:NSError = error as NSError;
        

        var desSrt = "";
        
        switch myerror.code {
        case 101:
            desSrt = "爱卿在抓梦脚，账号密码都输错了";
        case 210:
            desSrt = "爱卿在抓梦脚，原密码输错了";
        case 201:
            desSrt = "";
        case 201:
            desSrt = "";
        case 201:
            desSrt = "";
        case 201:
            desSrt = "";
        case 201:
            desSrt = "";
        case 201:
            desSrt = "";
        case 201:
            desSrt = "";
        default:
            desSrt = "未知错误";
        }
        return desSrt;
    
    }
}
